/*
 * This netstream.h from ShowEQ, modified to work with EQEmu Source
 *
 *  ShowEQ Distributed under GPL
 *  http://www.sourceforge.net/projects/seq
 *
 *  Copyright 2004 Zaphod (dohpaz@users.sourceforge.net). 
 *  modified by erde (2009)
 */

#ifndef _MEMSTREAM_H_
#define _MEMSTREAM_H_

#include "../common/types.h"
#include <string>

using namespace std;

class MemStream
{
 public:
  MemStream(const uint8* data, size_t length);
  ~MemStream();

  const uint8* data() { return m_data; }
  size_t length() { return m_length; }
  void reset();
  bool end() { return (m_pos >= m_lastPos); }
  const uint8* pos() { return m_pos; }

  uint8 readUInt8();
  int8 readInt8();
  uint16 readUInt16();
  int16 readInt16();
  uint32 readUInt32();
  int32 readInt32();
  string readText();
  uint16 readUInt16NC();
  uint32 readUInt32NC();
  void skipBytes(size_t byteCount);

 protected:
  const uint8* m_data;
  size_t m_length;
  const uint8* m_lastPos;
  const uint8* m_pos;
};

#endif // _MEMSTREAM_H_


